package com.hsy.managemoney.modules.my;

import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.VolleyError;
import com.deparse.dpframe.ui.fragment.DPBaseFragment;
import com.deparse.dpframe.utils.DPGsonUtil;
import com.deparse.dpframe.utils.DPHttpUtil;
import com.deparse.dpframe.utils.DPLogUtil;
import com.hsy.managemoney.R;
import com.hsy.managemoney.modules.common.Conts;
import com.hsy.managemoney.modules.jsondata.MyJsonData;
import com.hsy.managemoney.modules.utils.HttpUtil;

/**
 * Created by Administrator on 2016/10/11.
 */
public class FragmentMy extends DPBaseFragment {
    protected ImageView myHead;
    protected TextView isVip;
    protected TextView toVip;
    protected TextView frozenMoney;
    protected TextView totalMoney;
    protected TextView expectMoney;
    private DPHttpUtil.HttpCallback callBack = new DPHttpUtil.HttpCallback() {
        @Override
        public void onSuccess(int what, String response) {
            MyJsonData.Result myJsonData = DPGsonUtil.fromJson(response, MyJsonData.Result.class);
            frozenMoney.setText(myJsonData.getUser().getFrozen_amount());
            totalMoney.setText(myJsonData.getUser().getTotal_amount());
            expectMoney.setText("￥" + myJsonData.getUser().getExpect_amount());

        }

        @Override
        public void onError(int what, int type, VolleyError error) {

        }
    };

    @Override
    protected int getFragmentLayout() {
        return R.layout.fragment_my;
    }

    @Override
    protected void initView(View rootView, Bundle savedInstanceState) {
        myHead = (ImageView) rootView.findViewById(R.id.my_head);
        isVip = (TextView) rootView.findViewById(R.id.is_vip);
        toVip = (TextView) rootView.findViewById(R.id.to_vip);
        frozenMoney = (TextView) rootView.findViewById(R.id.frozen_money);
        totalMoney = (TextView) rootView.findViewById(R.id.total_money);
        expectMoney = (TextView) rootView.findViewById(R.id.expect_money);
        HttpUtil.httpGet(getAttchedActivity(), 0, Conts.Apis.GET_MY_MY, callBack);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onHandleMessage(Message msg) {

    }
}
